﻿#region << 文件说明 >>

/*----------------------------------------------------------------
 * 命名空间：Vampirewal.Core.SocketCore.Models
 * 唯一标识：9f42a698-ff72-4ec1-b61b-ffa838ea1d9c
 * 文件名：DynamicPropertyBaseModel
 *
 * 创建者：杨程
 * 电子邮箱：235160615@qq.com
 * 创建时间：2024/8/12 17:00:36
 * 版本：V1.0.0
 * 描述：
 *
 * ----------------------------------------------------------------
 * 修改人：
 * 时间：
 * 修改说明：
 *
 * 版本：V1.0.1
 *----------------------------------------------------------------*/

#endregion << 文件说明 >>

namespace Vampirewal.Core.SocketCore;

public delegate void PropertyChangedCallback<T>(DynamicObject dynamicObject, DynamicPropertyChangedEventArgs<T> e);

/// <summary>
/// 动态属性元数据
/// </summary>
/// <typeparam name="T"></typeparam>
public sealed class DynamicPropertyMetadata<T>
{
    /// <summary>
    ///
    /// </summary>
    /// <param name="defaultValue">默认值</param>
    public DynamicPropertyMetadata(T defaultValue)
    {
        DefaultValue = defaultValue;
    }

    /// <summary>
    ///
    /// </summary>
    /// <param name="defaultValue">默认值</param>
    /// <param name="callback">属性变更回调</param>
    public DynamicPropertyMetadata(T defaultValue, PropertyChangedCallback<T> callback)
    {
        DefaultValue = defaultValue;
        Callback = callback;
    }

    /// <summary>
    /// 默认值
    /// </summary>
    public T DefaultValue { get; private set; }

    /// <summary>
    /// 回调方法
    /// </summary>
    public PropertyChangedCallback<T> Callback { get; private set; }
}